package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.BaobeiBean;
import com.lwj.liwanjia.bean.DpBean;
import com.lwj.liwanjia.impl.BaobeiView;
import com.lwj.liwanjia.impl.DpView;
import com.lwj.liwanjia.model.BaobeiModel;
import com.lwj.liwanjia.model.DpModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/27.
 */

public class DpPresenter {
    private DpModel dpModel;
    private DpView dpView;

    public DpPresenter(DpView dpView) {
        this.dpView = dpView;
        dpModel = new DpModel();
    }

    public void getDpData(String token, String str) {
        if (dpView != null) {
            dpModel.getDpData(token, str, new Subscriber<DpBean>() {
                @Override
                public void onCompleted() {
                    dpView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    dpView.showError((Exception) e);
                    dpView.hideProgress();
                }

                @Override
                public void onNext(DpBean dpBean) {
                    dpView.getDpData(dpBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    dpView.showProgress();
                }
            });
        }
    }
}
